package com.yiidata.presto.clickhouse;

import com.facebook.airlift.configuration.Config;
import java.math.RoundingMode;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

public class ClickhouseConfig {

  private int varcharMaxSize = 4000;
  
  private int timestampDefaultPrecision = 6;
  
  private int numberDefaultScale = 10;
  
  private RoundingMode numberRoundingMode = RoundingMode.HALF_UP;
  
  @Min(0L)
  @Max(38L)
  public int getNumberDefaultScale() {
    return this.numberDefaultScale;
  }
  
  @Config("clickhouse.number.default-scale")
  public ClickhouseConfig setNumberDefaultScale(int numberDefaultScale) {
    this.numberDefaultScale = numberDefaultScale;
    return this;
  }
  
  @NotNull
  public RoundingMode getNumberRoundingMode() {
    return this.numberRoundingMode;
  }
  
  @Config("clickhouse.number.rounding-mode")
  public ClickhouseConfig setNumberRoundingMode(RoundingMode numberRoundingMode) {
    this.numberRoundingMode = numberRoundingMode;
    return this;
  }
  
  @Min(4000L)
  public int getVarcharMaxSize() {
    return this.varcharMaxSize;
  }
  
  @Config("clickhouse.varchar.max-size")
  public ClickhouseConfig setVarcharMaxSize(int varcharMaxSize) {
    this.varcharMaxSize = varcharMaxSize;
    return this;
  }
  
  @Min(0L)
  @Max(9L)
  public int getTimestampDefaultPrecision() {
    return this.timestampDefaultPrecision;
  }
  
  @Config("clickhouse.timestamp.precision")
  public ClickhouseConfig setTimestampDefaultPrecision(int timestampDefaultPrecision) {
    this.timestampDefaultPrecision = timestampDefaultPrecision;
    return this;
  }
}
